package acm.pta3;

import java.io.*;
import java.util.*;

public class T10 {
    static int[] list=new int[100000];
    static int len=0;
    public static int fun(int[] arr){
        for (int num : arr) {
//            insert(num,list);
            insert(num);
        }
        return len;
    }
    public static void insert(int n,List<Integer> list,int start,int end){
        if (start>end){
            if (start>=list.size()){
                list.add(start,n);
            }else {
                list.set(start,n);
            }
            return;
        }
        int mid=(start+end)/2;
        if (n==list.get(mid)){
            return;
        }
        if (n<list.get(mid)){
            insert(n,list,start,mid-1);
        }else {
            insert(n,list,mid+1,end);
        }
    }

    public static void insert(int n){
        int L=0;
        int R=len-1;
        int mid=0;
        while (L<=R){
            mid=(L+R)/2;
            Integer curr = list[mid];
            if (curr==n){
                return;
            }
            if (n<curr){
                R=mid-1;
            }else {
                L=mid+1;
            }
        }
        if (L>=len){
            list[len++]=n;
        }else {
            list[L]=n;
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
        int[] arr=new int[Integer.parseInt(in.readLine())];
        String[] read=in.readLine().split(" ");

        for (int i = 0; i < arr.length; i++) {
            arr[i]=Integer.parseInt(read[i]);
        }
        out.write((fun(arr)+"\n"));
        out.flush();
    }
}
